Let’s load some packages.
library(raster)
library(terra)
library(magrittr)
library(fs)
library(tidyverse)
library(sf)
library(tmap)
library(countrycode)
library(janitor)
Here the geographic data is read in.
world_outlines <-
st_read("data/World_Countries_(Generalized)_9029012925078512962.geojson") %>%
clean_names()
## Reading layer `World_Countries_(Generalized)_9029012925078512962' from data source `C:\Users\samwm\Documents\CASA\ucl_casa_gis\data\World_Countries_(Generalized)_9029012925078512962.geojson'
## using driver `GeoJSON'
## Simple feature collection with 251 features and 5 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -180 ymin: -89 xmax: 180 ymax: 83.6236
## Geodetic CRS: WGS 84
And here the Human Development Index (HDI) data
hdi_data <-
read_csv("data/HDR25_Composite_indices_complete_time_series.csv") %>%
clean_names()
And now we convert the from ISO2 to ISO3 country codes
world_outlines <- world_outlines %>%
mutate(iso3=countrycode(world_outlines[['iso']],origin = 'iso2c', destination = 'iso3c'))
And here we can join the two on the country code columns
joined = left_join(world_outlines,hdi_data,by=join_by(iso3))
Here the data is filtered to the Gender Inequality Index (GII) columns
list_of_relevance<-names(joined) %>%
str_detect(.,"gii_")
data_of_interest <- joined[list_of_relevance]
Here a new column is added, which holds the difference between the GII in 2019 and in 2010 for each nation, and that new column is plotted.
tmap_mode('view')
data_of_interest <- data_of_interest %>%
mutate(.,reduction = joined[['gii_2010']] - joined[['gii_2019']])
tm1 <- tm_shape(data_of_interest) +
tm_polygons(
fill = "reduction",
fill.legend = tm_legend(title="Absolute Reduction in GII 2010-2019",
title.size=0.85,
size=0.8,
# plot outside of the main map
#explained below
position=tm_pos_out("right",
"center",
pos.v = "center")))
tm1
Lots of countries look about the same here, except for Saudi Arabia
Maybe it would be more interesting to look at decline in gender inequality relative to it’s initial level at the start of the 2010 to 2019 interval.
data_of_interest <- data_of_interest %>%
mutate(.,percentage_reduction = 100*(1- (joined[['gii_2019']] / joined[['gii_2010']])))
tm1 <- tm_shape(data_of_interest) +
tm_polygons(
fill = "percentage_reduction",
fill.legend = tm_legend(title="% Reduction in GII 2010-2019",
title.size=0.85,
size=0.8,
# plot outside of the main map
#explained below
position=tm_pos_out("right",
"center",
pos.v = "center")))
tm1